<?php

/**
 * Application Models
 *
 * @package Application_Model
 * @subpackage Model
 * @author <YOUR NAME HERE>
 * @copyright ZF model generator
 * @license http://framework.zend.com/license/new-bsd     New BSD License
 */

/**
 * Abstract class for models
 */
require_once 'ModelAbstract.php';

/**
 * 
 *
 * @package Application_Model
 * @subpackage Model
 * @author <YOUR NAME HERE>
 */
class Application_Model_Parcours extends Application_Model_ModelAbstract
{

    /**
     * Database var type int(2)
     *
     * @var int
     */
    protected $_IdParcours;

    /**
     * Database var type varchar(100)
     *
     * @var string
     */
    protected $_LibelleParcours;

    /**
     * Database var type date
     *
     * @var date
     */
    protected $_DateCréationParcours;



    /**
     * Dependent relation fk_parcours_has_formation_parcours1
     * Type: One-to-Many relationship
     *
     * @var Application_Model_Ordre
     */
    protected $_Ordre;

    /**
     * Sets up column and relationship lists
     */
    public function __construct()
    {
        parent::init();
        $this->setColumnsList(array(
            'id_parcours'=>'IdParcours',
            'libelle_parcours'=>'LibelleParcours',
            'date_création_parcours'=>'DateCréationParcours',
        ));

        $this->setParentList(array(
        ));

        $this->setDependentList(array(
            'FkParcoursHasFormationParcours1' => array(
                    'property' => 'Ordre',
                    'table_name' => 'Ordre',
                ),
        ));
    }

    /**
     * Sets column id_parcours
     *
     * @param int $data
     * @return Application_Model_Parcours
     */
    public function setIdParcours($data)
    {
        $this->_IdParcours = $data;
        return $this;
    }

    /**
     * Gets column id_parcours
     *
     * @return int
     */
    public function getIdParcours()
    {
        return $this->_IdParcours;
    }

    /**
     * Sets column libelle_parcours
     *
     * @param string $data
     * @return Application_Model_Parcours
     */
    public function setLibelleParcours($data)
    {
        $this->_LibelleParcours = $data;
        return $this;
    }

    /**
     * Gets column libelle_parcours
     *
     * @return string
     */
    public function getLibelleParcours()
    {
        return $this->_LibelleParcours;
    }

    /**
     * Sets column date_création_parcours
     *
     * @param date $data
     * @return Application_Model_Parcours
     */
    public function setDateCréationParcours($data)
    {
        $this->_DateCréationParcours = $data;
        return $this;
    }

    /**
     * Gets column date_création_parcours
     *
     * @return date
     */
    public function getDateCréationParcours()
    {
        return $this->_DateCréationParcours;
    }

    /**
     * Sets dependent relations fk_parcours_has_formation_parcours1
     *
     * @param array $data An array of Application_Model_Ordre
     * @return Application_Model_Parcours
     */
    public function setOrdre(array $data)
    {
        $this->_Ordre = array();

        foreach ($data as $object) {
            $this->addOrdre($object);
        }

        return $this;
    }

    /**
     * Sets dependent relations fk_parcours_has_formation_parcours1
     *
     * @param Application_Model_Ordre $data
     * @return Application_Model_Parcours
     */
    public function addOrdre(Application_Model_Ordre $data)
    {
        $this->_Ordre[] = $data;
        return $this;
    }

    /**
     * Gets dependent fk_parcours_has_formation_parcours1
     *
     * @param boolean $load Load the object if it is not already
     * @return array The array of Application_Model_Ordre
     */
    public function getOrdre($load = true)
    {
        if ($this->_Ordre === null && $load) {
            $this->getMapper()->loadRelated('FkParcoursHasFormationParcours1', $this);
        }

        return $this->_Ordre;
    }

    /**
     * Returns the mapper class for this model
     *
     * @return Application_Model_Mapper_Parcours
     */
    public function getMapper()
    {
        if ($this->_mapper === null) {
            $this->setMapper(new Application_Model_Mapper_Parcours());
        }

        return $this->_mapper;
    }

    /**
     * Deletes current row by deleting the row that matches the primary key
     *
	 * @see Application_Model_Mapper_Parcours::delete
     * @return int|boolean Number of rows deleted or boolean if doing soft delete
     */
    public function deleteRowByPrimaryKey()
    {
        if ($this->getIdParcours() === null) {
            throw new Exception('Primary Key does not contain a value');
        }

        return $this->getMapper()
                    ->getDbTable()
                    ->delete('id_parcours = ' .
                             $this->getMapper()
                                  ->getDbTable()
                                  ->getAdapter()
                                  ->quote($this->getIdParcours()));
    }
}
